#include <iostream>
#include <vector>
#include <string>

size_t Split(const std::string &str,const std::string& sep,std::vector<std::string>&result)
{
    int pos,idx =0;
    while(idx < str.size())
    {
        pos = str.find(sep,idx);

        if(pos == std::string::npos)
        {
            result.push_back(str.substr(idx));
            return result.size();
        }

        if ((idx == pos))
        {
            idx += sep.size();
            continue;
        }

        result.push_back(str.substr(idx,pos-idx));
        idx = pos + sep.size();
    }

    return result.size();
}


int main()
{
    std::string s = "...news....music.#.pop...";
    std::vector<std::string> v;
    int n = Split(s,".",v);

    for(auto& a:v)
    {
        std::cout << a <<std::endl;
    }

    return 0;
}